<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet" href="../../styles/base/base.css" type="text/css" media="screen" />
</head>
<body style="background-color:#eeeeee;">
<pre style="color:#000000; background-color:#eeeeee; font-size:8pt; font-family:'Courier New';"><span style="color:#303030">   1 </span><span style="color:#bb7977; font-weight:bold">package</span> no<span style="color:#ff0080; font-weight:bold">.</span>knowit<span style="color:#ff0080; font-weight:bold">.</span>helloejb<span style="color:#ff0080; font-weight:bold">;</span>
<span style="color:#303030">   2 </span><span style="color:#bb7977; font-weight:bold">import</span> org<span style="color:#ff0080; font-weight:bold">.</span>testng<span style="color:#ff0080; font-weight:bold">.</span>Assert<span style="color:#ff0080; font-weight:bold">;</span>
<span style="color:#303030">   3 </span><span style="color:#bb7977; font-weight:bold">import</span> org<span style="color:#ff0080; font-weight:bold">.</span>testng<span style="color:#ff0080; font-weight:bold">.</span>annotations<span style="color:#ff0080; font-weight:bold">.</span>Test<span style="color:#ff0080; font-weight:bold">;</span>
<span style="color:#303030">   4 </span><span style="color:#bb7977; font-weight:bold">import</span> no<span style="color:#ff0080; font-weight:bold">.</span>knowit<span style="color:#ff0080; font-weight:bold">.</span>openejb<span style="color:#ff0080; font-weight:bold">.</span>mock<span style="color:#ff0080; font-weight:bold">.</span>OpenEjbTest<span style="color:#ff0080; font-weight:bold">;</span>
<span style="color:#303030">   5 </span>
<span style="color:#303030">   6 </span><span style="color:#bb7977; font-weight:bold">public class</span> HelloEjbTest <span style="color:#bb7977; font-weight:bold">extends</span> <strong style="color:green">OpenEjbTest</strong> <span style="color:#ff0080; font-weight:bold">{</span>
<span style="color:#303030">   7 </span>  <span style="color:#bb7977; font-weight:bold">private static final</span> <span style="color:#0080c0">String</span>  EXPECTED_HELLO <span style="color:#ff0080; font-weight:bold">=</span> <span style="color:#a68500">&quot;hello&quot;</span><span style="color:#ff0080; font-weight:bold">;</span>
<span style="color:#303030">   8 </span>
<span style="color:#303030">   9 </span>  &#64;Test
<span style="color:#303030">  10 </span>  <span style="color:#bb7977; font-weight:bold">public</span> <span style="color:#8080c0; font-weight:bold">void</span> <span style="color:#004466">shouldSayHello</span><span style="color:#ff0080; font-weight:bold">()</span>  <span style="color:#bb7977; font-weight:bold">throws</span> <span style="color:#0080c0">Exception</span> <span style="color:#ff0080; font-weight:bold">{</span>
<span style="color:#303030">  11 </span>
<span style="color:#303030">  12 </span>    HelloEjb hello <span style="color:#ff0080; font-weight:bold">= (</span>HelloEjb<span style="color:#ff0080; font-weight:bold">)</span>initialContext<span style="color:#ff0080; font-weight:bold">.</span><span style="color:#004466">lookup</span><span style="color:#ff0080; font-weight:bold">(</span><span style="color:#a68500">&quot;HelloEjbBean/Local&quot;</span><span style="color:#ff0080; font-weight:bold">);</span>
<span style="color:#303030">  13 </span>    assert hello <span style="color:#ff0080; font-weight:bold">!=</span> null <span style="color:#ff0080; font-weight:bold">:</span> <span style="color:#a68500">&quot;initialContext.lookup(</span><span style="color:#ff00ff; font-weight:bold">\&quot;</span><span style="color:#a68500">HelloEjbBean/Local</span><span style="color:#ff00ff; font-weight:bold">\&quot;</span><span style="color:#a68500">) returned null&quot;</span><span style="color:#ff0080; font-weight:bold">;</span>
<span style="color:#303030">  14 </span>
<span style="color:#303030">  15 </span>    Assert<span style="color:#ff0080; font-weight:bold">.</span><span style="color:#004466">assertEquals</span><span style="color:#ff0080; font-weight:bold">(</span>EXPECTED_HELLO<span style="color:#ff0080; font-weight:bold">,</span> hello<span style="color:#ff0080; font-weight:bold">.</span><span style="color:#004466">sayHello</span><span style="color:#ff0080; font-weight:bold">(),</span> <span style="color:#a68500">&quot;hello.sayHello:&quot;</span><span style="color:#ff0080; font-weight:bold">);</span>
<span style="color:#303030">  16 </span>  <span style="color:#ff0080; font-weight:bold">}</span>
<span style="color:#303030">  17 </span><span style="color:#ff0080; font-weight:bold">}</span>
</pre>
</body>
</html>
